package model;

import java.io.Serializable;
import java.util.ArrayList;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "day")
public class Day implements Serializable
{
	private static final long serialVersionUID = -1264240050143236465L;

	private static int i = 0;
	
	@XmlAttribute
	private String id = "";
	
	@XmlAttribute
	private String name = "";
	
	@XmlElement(name = "subject")
	private ArrayList<Subject> subjects = new ArrayList<Subject>();
	
	public Day() {}
	
	public Day(String name)
	{
		i++;
		this.id = i + "";
		this.name = name;
	}
	
	public String toString()
	{
		String out = "\n";
		for (int i = 0; i < subjects.size(); i++)
		{
			out += subjects.get(i) + "\n";
		}
		return "Day id(" + id + ") -> Name: " + name + out;
	}
	
	public Subject createSubject(Time time, String name, String type, Warning warning)
	{
		Subject subject = new Subject(time, name, type, warning);
		subjects.add(subject);
		return subject;
	}
	
	public Subject createSubject(String subGroup, Time time, String name, String type, Warning warning)
	{
		Subject subject = new Subject(subGroup, time, name, type, warning);
		subjects.add(subject);
		return subject;
	}

	public ArrayList<Subject> getSubjects()
	{
		return subjects;
	}

	public String getId()
	{
		return id;
	}

	public String getName()
	{
		return name;
	}
}